package test1;


import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;

/**
 * HashedCredentialsMatcher密码服务
 * @author H.A
 * 2019年4月8日
 */
public class MyRealm6 extends AuthorizingRealm{

	/**
	 * 检校用户权限
	 * @return null
	 */
	protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection pricipalCollection){
		
		return null;
	}
	
	/**
	 * 检校用户信息是否正确
	 * @param token 用户输入的信息
	 * @return authentication 经过加密的信息 
	 */
	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)throws AuthenticationException{
		String userName= "liu";
		String salt2= "0072273a5d87322163795118fdd7c45e";
		String password= "be320beca57748ab9632c4121ccac0db";
		SimpleAuthenticationInfo authentication= new SimpleAuthenticationInfo(userName,password,getName());
		authentication.setCredentialsSalt(ByteSource.Util.bytes(userName+salt2));
		return authentication;
	}
	
}
